package com.lmmob.autotest.uitest.controls;

import org.openqa.selenium.WebDriver;

public class TabPanel extends CompositeControl {

    private String query;
    private String title;

    public TabPanel(Integer index, WebDriver webDriver) {
        super(webDriver);
        this.query = String.format(".query(\"tabpanel\")[%s]", index);
    }

    public TabPanel(String title, WebDriver webDriver) {
        super(webDriver);
        this.title = title;
        this.query = String.format(".query(\"tabpanel[title='%s']\")[0]", title);
    }

    public void show() {
        runScript(getQuery() + ".show()");
    }

    @Override
    protected String getSelfQuery() {
        return query;
    }

    @Override
    protected String getName() {
        return this.title;
    }
}
